﻿using System;
using System.Linq;
using System.Linq.Expressions;
using OutDbContext;
using User.Api.Helpers;

namespace User.Api.BizExtensions
{
    public static class MicroPayOrderExtensions
    {
        public static IQueryable<MicroPayOrder> IsStatus(this IQueryable<MicroPayOrder> source,
            params OrderStatus[] orderStatuses)
        {
            if (orderStatuses.Length <= 0)
            {
                return source;
            }

            var intOrderStatus = (int)orderStatuses[0];
            Expression<Func<MicroPayOrder, bool>> expression = x => int.Parse(x.OrderStatus) == intOrderStatus;

            for (int i = 1; i < orderStatuses.Length; i++)
            {
                var intOrderStatus2 = (int)orderStatuses[i];
                var expressionHelper = new ExpressionHelper<MicroPayOrder>();
                expression = expressionHelper.BuildQueryOr(expression, x => int.Parse(x.OrderStatus) == intOrderStatus2);
            }

            return source.Where(expression);
        }

        //支付状态：0未支付 1支付中 2支付成功 3支付失败 4退款中 
        //5退款成功 6退款失败 7缴费中 8缴费成功 9缴费失败 10窗口退款成功
        public enum OrderStatus
        {
            未支付 = 0,
            支付中 = 1,
            支付成功 = 2,
            支付失败 = 3,
            退款中 = 4,
            退款成功 = 5,
            退款失败 = 6,
            缴费中 = 7,
            缴费成功 = 8,
            缴费失败 = 9,
            窗口退款成功 = 10,
            撤销成功 = 11
        }
        
        /// <summary>
        /// 支付状态:0-未付款,1-已付款,2-退款中,3-已退款,4-退款失败
        /// </summary>
        public enum PayState
        {
            未付款 = 0,
            已付款 = 1,
            退款中 = 2,
            已退款 = 3,
            退款失败 = 4,
            已撤销 = 5
        }

        /// <summary>
        /// 0：未使用医保，1：使用了医保，2：取消了医保，3：取消医保失败，4：获取医保失败
        /// </summary>
        public enum YiBaoStatus
        {
            未使用医保 = 0,
            使用了医保 = 1,
            取消了医保 = 2,
            取消医保失败 = 3,
            获取医保失败 = 4,
            取消医保中 = 5
        }

        /// <summary>
        /// 支付方式
        /// </summary>
        public enum PayType
        {

            一般支付 = 0,
            扫码支付 = 1,
            扫码链接 = 2,
            刷卡支付 = 3


        }
    }
}